import request from '@/utils/request';


/**
 * 获取城市列表
 * @param params 查询参数
 * @returns 城市列表数据
 */
export const getCityList = async (params?: CityQueryParams): Promise<PageList<CityInfo>> =>request.get('/cities', params);

/**
 * 获取城市详情
 * @param id 城市ID
 * @returns 城市详情
 */
export const getCityById = async (id: number) => request.get(`/cities/${id}`);

/**
 * 创建城市
 * @param data 城市数据
 * @returns 创建结果
 */
export const createCity = async (data: CityCreateData) => {
  const { data: result } = await request.post('/cities', data);
  return result;
};

/**
 * 更新城市
 * @param id 城市ID
 * @param data 更新数据
 * @returns 更新结果
 */
export const updateCity = async (id: number, data: CityUpdateData) => await request.put(`/cities/${id}`, data);

/**
 * 删除城市
 * @param id 城市ID
 * @returns 删除结果
 */
export const deleteCity = async (id: number) => {
  const { data } = await request.delete(`/cities/${id}`);
  return data;
};

/**
 * 批量删除城市
 * @param data 批量删除数据
 * @returns 删除结果
 */
export const batchDeleteCity = async (data: CityBatchDeleteRequest) => {
  const { data: result } = await request.post('/cities/batch-delete', data);
  return result;
};